package Thread_.homework;

public class test13 {
    public static void main(String[] args) {

        Thread t1=new Thread(){
            @Override
            public void run() {
                synchronized (this){
                    while(true){
                        System.out.println("haha");
                        try {
                            this.wait();//此时t线程处于WAITING状态
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        try {
                            this.wait(5000);//超时等待，此时t线程处于TIMED_WAITING状态
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                        //                    try {
    //                        Thread.sleep(1000);//此时t线程处于TIMED_WAITING状态
    //                    } catch (InterruptedException e) {
    //                        throw new RuntimeException(e);
    //                    }
                    }

                }
            }
        };
        t1.start();

        try {
            t1.join();//此时，main线程处于WAITING状态
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

    }
}
